package cn.yunhe.action;

import cn.yunhe.entity.House;
import cn.yunhe.entity.Page;
import cn.yunhe.service.UserService;
import com.opensymphony.xwork2.ModelDriven;

import java.util.List;

public class HouseAction extends  BaseAction implements  ModelDriven<Object>{
     private Page page;
     private int pageIndex;
     private House house;

    @Override
    public String execute(){
        page = new Page();
        UserService userService = new UserService();
        List<House>  houseList= userService.news(pageIndex,house.getTitle());
        page.setHouseList(houseList);
        page.setPageIndex(pageIndex);
        page.setTotalPages(userService.getTotalPages());
        return  SUCCESS;
    }
    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
    public House getHouse() {
        return house;
    }

    public void setHouse(House house) {
        this.house = house;
    }
  public   House getModel(){
        if(house == null){
            house = new House();
        }
        return house;
  }

}
